package org.bozo.im.common.types;

import org.bozo.im.R;

import android.os.Parcel;
import android.os.Parcelable;

public enum Protocol implements Parcelable {

	XMPP,
	FACEBOOK,
	GTALK,
	FAKE;

	public int getRessourceId() {

		int lRes = -1;

		switch (this) {
		case FAKE:
			lRes = R.string.protocol_fake;
			break;
		case GTALK:
			lRes = R.string.protocol_gtalk;
			break;
		case FACEBOOK:
			lRes = R.string.protocol_facebook;
			break;
		default:
			lRes = R.string.protocol_fake;

		}

		return lRes;
	}

	public int getImageId() {

		int lRes = -1;

		switch (this) {
		case FAKE:
			lRes = R.drawable.protocol_gtalk;
			break;
		case GTALK:
			lRes = R.drawable.protocol_gtalk;
			break;
		case FACEBOOK:
			lRes = R.drawable.protocol_gtalk;
			break;
		default:
			lRes = R.drawable.protocol_gtalk;

		}

		return lRes;
	}
	
	public String toIntentProtocol() {
		
		String lRes = null;
		
		switch (this) {
		case GTALK:
			lRes = "gtalk";
			break;
		case FACEBOOK:
			lRes = "facebook";
			break;
		case FAKE:
			lRes = "fake";
			break;
		}
		
		return lRes;
	}
	
	public int describeContents() {
		return 0;
	}

	public void writeToParcel(Parcel pParcel, int pI) {
		pParcel.writeString(this.name());
	}

	public static final Parcelable.Creator<Protocol> CREATOR = new Creator<Protocol>() {

		public Protocol[] newArray(int pI) {
			return new Protocol[pI];
		}

		public Protocol createFromParcel(Parcel pParcel) {
			return Protocol.valueOf(pParcel.readString());
		}
	};

}
